import {
  BwComPropSetConstValueComEnum,
  BwCustomComPropDataTypeEnum,
  BwCustomComEmitParamDataTypeEnum,
  BwCustomComSlotParamDataTypeEnum,
  BwCustomComSoltTypeEnum,
} from '../../../render/models'
import type {
  BwCustomComEmitInfoModel,
  BwCustomComSlotInfoModel,
  BwCustomComPropInfoModel,
} from '../../../render/models'

/** 组件属性 */
const comAttrs: Array<BwCustomComPropInfoModel> = [
  {
    key: 'class',
    name: 'classNames',
    isRequire: false,
    defaultValue: undefined,
    dataType: [
      BwCustomComPropDataTypeEnum.string,
      BwCustomComPropDataTypeEnum.array,
    ],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'modelValue',
    name: '值(v-model)',
    isModel: true,
    isRequire: false,
    defaultValue: undefined,
    dataType: [
      BwCustomComPropDataTypeEnum.number,
      BwCustomComPropDataTypeEnum.string,
    ],
    defaultValueDataType: BwCustomComPropDataTypeEnum.number,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'label',
    name: '输入框左侧文本',
    isRequire: false,
    defaultValue: undefined,
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'name',
    name: '名称，作为提交表单时的标识符',
    isRequire: false,
    defaultValue: undefined,
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'id',
    name: '输入框id',
    isRequire: false,
    defaultValue: undefined,
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'type',
    name: '输入框类型',
    isRequire: false,
    defaultValue: 'text',
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'size',
    name: '大小',
    isRequire: false,
    defaultValue: undefined,
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.select,
    constValueSetComProps: JSON.stringify({
      options: [
        {
          label: '默认',
          value: 'default',
        },
        {
          label: '大',
          value: 'large',
        },
      ],
    }),
    remark: '',
  },
  {
    key: 'maxlength',
    name: '输入的最大字符数',
    isRequire: false,
    defaultValue: undefined,
    dataType: [
      BwCustomComPropDataTypeEnum.string,
      BwCustomComPropDataTypeEnum.number,
    ],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.number,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'placeholder',
    name: '占位提示',
    isRequire: false,
    defaultValue: undefined,
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'border',
    name: '是否显示内边框',
    isRequire: false,
    defaultValue: 'true',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'disabled',
    name: '是否禁用输入框',
    isRequire: false,
    defaultValue: 'false',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'readonly',
    name: '是否只读',
    isRequire: false,
    defaultValue: 'false',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'colon',
    name: '是否在label后面添加冒号',
    isRequire: false,
    defaultValue: 'false',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'required',
    name: '是否必填',
    isRequire: false,
    defaultValue: undefined,
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'center',
    name: '是否使内容垂直居中',
    isRequire: false,
    defaultValue: 'false',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'clearable',
    name: '清除图标',
    isRequire: false,
    defaultValue: 'false',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'clear-icon',
    name: '清除图标名称或图片链接',
    isRequire: false,
    defaultValue: 'clear',
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'clear-trigger',
    name: '显示清除图标的时机',
    isRequire: false,
    defaultValue: 'focus',
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.select,
    constValueSetComProps: JSON.stringify({
      options: [
        {
          label: '不为空时',
          value: 'always',
        },
        {
          label: '聚焦且不为空时',
          value: 'focus',
        },
      ],
    }),
    remark: '',
  },
  {
    key: 'clickable',
    name: '是否开启点击反馈',
    isRequire: false,
    defaultValue: 'false',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'is-link',
    name: '是否展示右侧箭头并开启点击反馈',
    isRequire: false,
    defaultValue: 'false',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'autofocus',
    name: '是否自动聚焦',
    isRequire: false,
    defaultValue: 'false',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'show-word-limi',
    name: '字数统计',
    isRequire: false,
    defaultValue: 'false',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'error',
    name: '输入内容标红',
    isRequire: false,
    defaultValue: 'false',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'error-message',
    name: '底部错误提示文案',
    isRequire: false,
    defaultValue: undefined,
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'error-message-align',
    name: '错误提示文案对齐方式',
    isRequire: false,
    defaultValue: 'left',
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.select,
    constValueSetComProps: JSON.stringify({
      options: [
        {
          label: '左对齐',
          value: 'left',
        },
        {
          label: '居中',
          value: 'center',
        },
        {
          label: '右对齐',
          value: 'right',
        },
      ],
    }),
    remark: '',
  },
  // {
  //   key: 'formatter',
  //   name: '输入内容格式化函数',
  //   isRequire: false,
  //   defaultValue: 'left',
  //   dataType: [BwCustomComPropDataTypeEnum.function],
  //   defaultValueDataType: BwCustomComPropDataTypeEnum.function,
  //   constValueSetCom: BwComPropSetConstValueComEnum.function,
  //   constValueSetComProps: null,
  //   remark: '',
  // },
  {
    key: 'format-trigger',
    name: '格式化函数触发的时机',
    isRequire: false,
    defaultValue: 'onChange',
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.select,
    constValueSetComProps: JSON.stringify({
      options: [
        {
          label: '输入内容改变时',
          value: 'onChange',
        },
        {
          label: '失焦时',
          value: 'onBlur',
        },
      ],
    }),
    remark: '',
  },
  {
    key: 'arrow-direction',
    name: '箭头方向',
    isRequire: false,
    defaultValue: 'right',
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.select,
    constValueSetComProps: JSON.stringify({
      options: [
        {
          label: '左',
          value: 'left',
        },
        {
          label: '上',
          value: 'up',
        },
        {
          label: '右',
          value: 'right',
        },
        {
          label: '下',
          value: 'down',
        },
      ],
    }),
    remark: '',
  },
  {
    key: 'label-class',
    name: '左侧文本额外类名',
    isRequire: false,
    defaultValue: undefined,
    dataType: [
      BwCustomComPropDataTypeEnum.string,
      BwCustomComPropDataTypeEnum.array,
      BwCustomComPropDataTypeEnum.object,
    ],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'label-width',
    name: '左侧文本宽度',
    isRequire: false,
    defaultValue: '6.2em',
    dataType: [
      BwCustomComPropDataTypeEnum.string,
      BwCustomComPropDataTypeEnum.number,
    ],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'label-align',
    name: '左侧文本对齐方式',
    isRequire: false,
    defaultValue: 'left',
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.select,
    constValueSetComProps: JSON.stringify({
      options: [
        {
          label: '左对齐',
          value: 'left',
        },
        {
          label: '居中',
          value: 'center',
        },
        {
          label: '右对齐',
          value: 'right',
        },
        {
          label: '上',
          value: 'top',
        },
      ],
    }),
    remark: '',
  },
  {
    key: 'input-align',
    name: '输入框对齐方式',
    isRequire: false,
    defaultValue: 'left',
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.select,
    constValueSetComProps: JSON.stringify({
      options: [
        {
          label: '左对齐',
          value: 'left',
        },
        {
          label: '居中',
          value: 'center',
        },
        {
          label: '右对齐',
          value: 'right',
        },
      ],
    }),
    remark: '',
  },
  {
    key: 'autosize',
    name: 'textarea自适应内容高度',
    isRequire: false,
    defaultValue: 'false',
    dataType: [
      BwCustomComPropDataTypeEnum.boolean,
      BwCustomComPropDataTypeEnum.object,
    ],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'left-icon',
    name: '左侧图标名称或图片链接',
    isRequire: false,
    defaultValue: undefined,
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'right-icon',
    name: '右侧图标名称或图片链接',
    isRequire: false,
    defaultValue: undefined,
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'icon-prefix',
    name: '图标类名前缀',
    isRequire: false,
    defaultValue: 'van-icon',
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'rules',
    name: '表单校验规则',
    isRequire: false,
    defaultValue: undefined,
    dataType: [BwCustomComPropDataTypeEnum.array],
    defaultValueDataType: BwCustomComPropDataTypeEnum.array,
    constValueSetCom: BwComPropSetConstValueComEnum.textarea,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'autocomplete',
    name: '自动完成功能',
    isRequire: false,
    defaultValue: undefined,
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'autocapitalize',
    name: '输入时是否自动大写',
    isRequire: false,
    defaultValue: undefined,
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'enterkeyhint',
    name: '控制回车键样式',
    isRequire: false,
    defaultValue: undefined,
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'spellcheck',
    name: '检查元素的拼写错误',
    isRequire: false,
    defaultValue: undefined,
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'autocorrect',
    name: '仅 Safari 适用，用于自动更正输入的文本',
    isRequire: false,
    defaultValue: undefined,
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: null,
    remark: '',
  },
]

/** 组件事件 */
const comEmits: Array<BwCustomComEmitInfoModel> = [
  {
    key: 'update:modelValue',
    name: '输入框内容变化时触发',
    isModel: true,
    params: [
      {
        paramKey: 'value',
        paramName: '值',
        paramDataType: BwCustomComEmitParamDataTypeEnum.string,
        remark: '',
      },
    ],
  },
  {
    key: 'focus',
    name: '输入框获得焦点时触发',
    params: [
      {
        paramKey: 'event',
        paramName: 'Event',
        paramDataType: BwCustomComEmitParamDataTypeEnum.object,
        remark: '',
      },
    ],
  },
  {
    key: 'blur',
    name: '输入框失去焦点时触发',
    params: [
      {
        paramKey: 'event',
        paramName: 'Event',
        paramDataType: BwCustomComEmitParamDataTypeEnum.object,
        remark: '',
      },
    ],
  },
  {
    key: 'clear',
    name: '	点击清除按钮时触发',
    params: [
      {
        paramKey: 'event',
        paramName: 'MouseEvent',
        paramDataType: BwCustomComEmitParamDataTypeEnum.object,
        remark: '',
      },
    ],
  },
  {
    key: 'click',
    name: '点击组件时触发',
    params: [
      {
        paramKey: 'event',
        paramName: 'MouseEvent',
        paramDataType: BwCustomComEmitParamDataTypeEnum.object,
        remark: '',
      },
    ],
  },
  {
    key: 'click-input',
    name: '点击输入区域时触发',
    params: [
      {
        paramKey: 'event',
        paramName: 'MouseEvent',
        paramDataType: BwCustomComEmitParamDataTypeEnum.object,
        remark: '',
      },
    ],
  },
  {
    key: 'click-left-icon',
    name: '点击左侧图标时触发',
    params: [
      {
        paramKey: 'event',
        paramName: 'MouseEvent',
        paramDataType: BwCustomComEmitParamDataTypeEnum.object,
        remark: '',
      },
    ],
  },
  {
    key: 'click-right-icon',
    name: '点击右侧图标时触发',
    params: [
      {
        paramKey: 'event',
        paramName: 'MouseEvent',
        paramDataType: BwCustomComEmitParamDataTypeEnum.object,
        remark: '',
      },
    ],
  },
  {
    key: 'click-right-icon',
    name: '点击右侧图标时触发',
    params: [
      {
        paramKey: 'event',
        paramName: 'MouseEvent',
        paramDataType: BwCustomComEmitParamDataTypeEnum.object,
        remark: '',
      },
    ],
  },
  {
    key: 'start-validate',
    name: '开始表单校验时触发',
    params: [],
  },
  {
    key: 'end-validate',
    name: '结束表单校验时触发	',
    params: [
      {
        paramKey: 'status',
        paramName: '状态',
        paramDataType: BwCustomComEmitParamDataTypeEnum.string,
        remark: '',
      },
      {
        paramKey: 'message',
        paramName: '信息',
        paramDataType: BwCustomComEmitParamDataTypeEnum.string,
        remark: '',
      },
    ],
  },
]

/** 组件插槽 */
const comSlots: Array<BwCustomComSlotInfoModel> = [
  {
    slotType: BwCustomComSoltTypeEnum.convention,
    conventionSlotInfo: {
      slotCode: 'label',
      slotName: '自定义输入框左侧文本',
    },
  },
  {
    slotType: BwCustomComSoltTypeEnum.convention,
    conventionSlotInfo: {
      slotCode: 'input',
      slotName: '自定义输入框',
    },
  },
  {
    slotType: BwCustomComSoltTypeEnum.convention,
    conventionSlotInfo: {
      slotCode: 'left-icon',
      slotName: '自定义输入框头部图标',
    },
  },
  {
    slotType: BwCustomComSoltTypeEnum.convention,
    conventionSlotInfo: {
      slotCode: 'right-icon',
      slotName: '自定义输入框尾部图标',
    },
  },
  {
    slotType: BwCustomComSoltTypeEnum.convention,
    conventionSlotInfo: {
      slotCode: 'button',
      slotName: '自定义输入框尾部按钮',
    },
  },
  {
    slotType: BwCustomComSoltTypeEnum.convention,
    conventionSlotInfo: {
      slotCode: 'error-message',
      slotName: '自定义底部错误提示文案',
      slotParams: [
        {
          paramKey: 'message',
          paramName: '错误信息',
          paramDataType: BwCustomComSlotParamDataTypeEnum.string,
          remark: '',
        },
      ],
    },
  },
  {
    slotType: BwCustomComSoltTypeEnum.convention,
    conventionSlotInfo: {
      slotCode: 'extra',
      slotName: '自定义输入框最右侧的额外内容',
    },
  },
]

export const vantFieldInfo = {
  comAttrs,
  comEmits,
  comSlots,
}
